<template>
  <div class="material-card flex-row">
    <div class="info flex-column flex-start-center">
        <div class="name" :title="title">{{title}}</div>
        <div class="sale flex-row">
            <div v-if="false" class="price">￥{{price}}</div>
            <div class="tag">{{tag}}</div>
        </div>
    </div>
    <div class="operation flex-column flex-center">
        <a-button shape="round" @click="doDownload" danger>{{buttonLabel}}</a-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MaterialCard',
  props: {
    title: String,
    price: String,
    tag: {
        type: String,
        default: '限时免费'
    },
    buttonLabel: {
        type: String,
        default: '立即下载'
    },
  },
  data () {
    return {
    }
  },
  methods: {
    doDownload() {
        this.$emit('onDownload');
    }
  }
}
</script>

<style lang="less" scoped>
.material-card {
    width: calc(50% - 10px);
    height: 90px;
    padding: 20px;
    box-shadow: 0px 2px 10px 0px @box-shadow-color;
    border-radius: 12px;
    background: @white;

    .info {
        width: calc(100% - 130px);
        .name {
            width: 100%;
            height: 20px;
            line-height: 20px;
            font-size: 20px;
            font-weight: 500;
            color: @font-black;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .sale {
            margin-top: 10px;
            .price {
                height: 20px;
                line-height: 20px;
                font-size: 16px;
                color: @font-grey-light;
                text-decoration: line-through;
            }
            .tag {
                height: 20px;
                line-height: 20px;
                font-size: 20px;
                font-weight: bold;
                color: @red-light;
            }
        }
    }
    .operation {
        width: 120px;
        margin-left: 10px;
    }

    :deep(.ant-btn-default.ant-btn-dangerous) {
        color: @red;
        border-color: @red;
    }

    :deep(.ant-btn) {
        height: 40px;
        padding: 9px 28px;

        &.ant-btn-round {
            border-radius: 20px;
            padding-inline-start: 28px;
            padding-inline-end: 28px;
        }
        >span {
            font-size: 16px;
            font-weight: 500;
            line-height: 22px;
        }
    }
    
}
</style>
